<html>
<head><meta charset="utf-8"><title>CString ergonomics · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/CString.20ergonomics.html">CString ergonomics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227482661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/CString%20ergonomics/near/227482661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/CString.20ergonomics.html#227482661">(Feb 23 2021 at 18:47)</a>:</h4>
<p>I can imagine this comes up pretty often, but are there any plans to detect dangling <code>CString</code>s? Just spotted one here: <a href="https://github.com/georust/gdal/pull/153/files#diff-b0b3f516e4a8d589b9f4d18fa849158e60b50f7ed974d69533b58bbe082ddc2bR549-R561">https://github.com/georust/gdal/pull/153/files#diff-b0b3f516e4a8d589b9f4d18fa849158e60b50f7ed974d69533b58bbe082ddc2bR549-R561</a></p>



<a name="227487132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/CString%20ergonomics/near/227487132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/CString.20ergonomics.html#227487132">(Feb 23 2021 at 19:14)</a>:</h4>
<p>There is partial support via <a href="https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#temporary-cstring-as-ptr"><code>temporary-cstring-as-ptr</code></a>, but unfortunately that only works with temporaries.</p>



<a name="227487647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/CString%20ergonomics/near/227487647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/CString.20ergonomics.html#227487647">(Feb 23 2021 at 19:18)</a>:</h4>
<p>Could <code>clippy</code> detect that <code>match</code> consumes  the <code>CString</code> and the pointer is left dangling (in my example)?</p>



<a name="227547603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/CString%20ergonomics/near/227547603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/CString.20ergonomics.html#227547603">(Feb 24 2021 at 04:44)</a>:</h4>
<p>I think in theory it could since IIRC clippy does have some MIR-based lints that could use liveness info.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>